package org.spring.batch.ch06;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spring.batch.ch05.model.Group;

public class RestartItemWriter implements org.springframework.batch.item.ItemWriter<Object> {

	private final Logger logger = LoggerFactory.getLogger(getClass());

	@Override
	public void write(List<? extends Object> items) throws Exception {
		logger.info("=====>>RstartItemWriter, Count={}", items.size());
		for (Object obj : items) {
			Group group = null;
			if (obj instanceof Group) {
				group = (Group) obj;
				logger.info("Group:{}", group);
				if (group.getId() % 3 == 0) {
					throw new IllegalArgumentException("抛个异常吧");
				}
			}
		}
	}

}
